import BaseApi from "@/api/BaseApi"

import type LoginReq from "@/type/LoginReq.ts";
import type SysUserDetailResp from "@/type/resp/sys-user-detail-resp.ts";

class LoginApi extends BaseApi {

    constructor() {
        super('/sys')
    }

    /**
     * 登录
     * @param loginReq 登录时携带的数据
     */
    doLogin = (loginReq: LoginReq) => {
        return this.post<SysUserDetailResp, LoginReq>("doLogin", loginReq)
    }

    /**
     * 根据token获取在线用户详情
     */
    getUserDetailByToken = () => {
        return this.get<SysUserDetailResp>("queryDetailByToken")
    }

    /**
     * 获取登录验证码
     */
    getCaptcha = () => {
        return this.get<any>("getCaptcha")
    }

    /**
     * 退出
     */
    logout = () => {
        return this.get<string>("logout")
    }
}

export default new LoginApi()
